package com.bistu.sim.xwy.news.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bistu.sim.xwy.news.R;
import com.bistu.sim.xwy.news.domain.BusInfo;
import com.loopj.android.image.SmartImageView;

import java.util.List;

public class BusAdapter extends BaseAdapter {

    private List<BusInfo> busInfos;
    private Context context;
    public BusAdapter(List<BusInfo> busInfos, Context context){
        this.busInfos=busInfos;
        this.context=context;
    }
    @Override
    public int getCount() {
        return busInfos.size();
    }

    @Override
    public Object getItem(int position) {
        return busInfos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(context, R.layout.bus_item,null);
        SmartImageView siv_pic = (SmartImageView)view.findViewById(R.id.bus_icon);
        TextView bus_name=(TextView)view.findViewById(R.id.bus_name);
//        TextView tv_description = (TextView)view.findViewById(R.id.tv_description);
        TextView goods_name=(TextView)view.findViewById(R.id.goods_name);
        TextView goods_content=(TextView)view.findViewById(R.id.goods_content);
        TextView goods_price=(TextView)view.findViewById(R.id.goods_price);

        BusInfo busInfo = busInfos.get(position);
        
        siv_pic.setImageUrl(busInfo.getBus_icon(),R.drawable.ic_launcher,R.drawable.ic_launcher);
        bus_name.setText(busInfo.getBus_name());
        goods_name.setText(busInfo.getBus_name());
        goods_content.setText(busInfo.getBus_brief());
        goods_price.setText(busInfo.getBus_price());

        return view;
    }
}
